package com.togo.exam;

/**
 * @Author K2
 * @Description TODO
 * @Date 上午10:22 2023/2/16
 **/
public class DP {

    public int handle(int[] arr) {

        if (arr == null || arr.length == 0) return 0;

        int[] dp = new int[arr.length];
        dp[0] = arr[0];
        int max = 0;
        for (int i = 1; i < arr.length; i++) {
            dp[i] = dp[i - 1] > 0 ? dp[i - 1] + arr[i] : arr[i];
            max = Math.max(max, dp[i]);
        }

        return max;
    }
}
